package cn.zswltech.gruul.web.api.controller;

import cn.zswltech.gruul.api.UserOperationApi;
import cn.zswltech.gruul.common.dal.tkmybatis.BasePage;
import cn.zswltech.lib.futurelog.save.model.cmd.FutureLogQueryCmd;
import cn.zswltech.lib.futurelog.save.model.vo.FutureLogVO;
import cn.zswltech.lib.futurelog.save.service.FutureLogService;
import cn.zswltech.gruul.common.result.Response;
import cn.zswltech.gruul.web.api.controller.common.BaseController;
import cn.zswltech.lib.futurelog.save.util.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserOperationController extends BaseController implements UserOperationApi {

    @Resource
    private FutureLogService futureLogService;


    @Override
    public Response getOperTypeList(){
        return Response.success(futureLogService.getOperTypeList());
    }

    /**
     * 查询操作日志列表
     */
    @Override
    public Response getUserOperationList(FutureLogQueryCmd queryCmd) {
        //为符合前端的统一字段描述，对jar内的接口返回的数据进行二次封装
        Page<FutureLogVO> page = futureLogService.queryByCondition(queryCmd);
        return Response.success(new BasePage<>(page.getTotal(),page.getContents()));
    }


    @Override
    public Response deleteOperationLog(int id){
        futureLogService.deleteById(id);
        return Response.success(null);
    }
}
